import { getTokenInfo } from '@/utils/storage'

export type Auth = {
  token: string
  refresh_token: string
}
const initState = {
  profile: {},
  auth: getTokenInfo() || ({} as Auth),
}
type Action = {
  type: 'user/setToekn'
  payload: Auth
}
export default function userReducer(state = initState, action: Action) {
  switch (action.type) {
    case 'user/setToekn':
      return {
        ...state,
        auth: action.payload,
      }
    default:
      return state
  }
}
